const { defineConfig } = require("@vue/cli-service");
const path = require("path");
function resolve(dir) {
  return path.resolve(dir);
}

console.log(process.env);

module.exports = defineConfig({
  publicPath: ".",
  transpileDependencies: true,
  lintOnSave: false,
  //开发服务器配置
  devServer: {
    //配置启动服务器的端口号
    port: parseInt(process.env.VUE_APP_PORT),
    //配置地理
    proxy: {
      "/api": {
        //目标服务器
        target: process.env.VUE_APP_BASH_URL,
        //路径重写
        pathRewrite: {
          "^/api": "",
        },
      },
    },
  },
  //别名配置
  chainWebpack: (config) => {
    config.resolve.alias
      .set("&", resolve("src"))
      .set("assets", resolve("src/assets"))
      .set("components", resolve("src/components"))
      .set("layout", resolve("src/layout"))
      .set("base", resolve("src/base"))
      .set("static", resolve("src/static"));

    config.output
      .filename(
        `assets/js/[name].${process.env.VUE_APP_VERSION}.${+new Date()}.js`
      )
      .chunkFilename(
        `assets/js/[name].${process.env.VUE_APP_VERSION}.${+new Date()}.js`
      )
      .end();
  },
});
